package cn.ml.chuji.oop.zuChe;

public class ZuLin {
    //汽车类型的数组
    public MotoVehicle[] motos = new MotoVehicle[8];

    //初始化汽车信息
    public void init(){
        motos[0] = new Car("京A","宝马",800,"X6");
        motos[1] = new Car("京B","宝马",600,"550i");
        motos[2] = new Car("京C","别克",300,"林荫大道");
        motos[3] = new Car("京D","别克",600,"GL8");

        motos[4] = new Bus("京E","金杯",800,8);
        motos[5] = new Bus("京F","金龙",1500,34);
        motos[6] = new Bus("京J","金杯",800,16);
        motos[7] = new Bus("京H","金龙",1500,34);
    }
    //租车
    public MotoVehicle motoLeaseOut(String brand,String type,int seat){
        MotoVehicle moto = null;
        for(MotoVehicle m:motos){
            if(m instanceof Car){
                Car car = (Car) m;
                if(car.getBrand().equals(brand) && car.getType().equals(type)){
                    moto = car;
                    break;
                }
            }else {
                Bus bus = (Bus) m;
                if (bus.getBrand().equals(brand) && bus.getSeatCount() == seat){
                    moto = bus;
                    break;
                }
            }
        }
        return  moto;
    }


}
